<!DOCTYPE html>
<html>
<#include "/views/ftl/base/manager_include.ftl">
<script type="text/javascript" src="${basePath}js/My97DatePicker/WdatePicker.js"></script>
<base href="${basePath}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>产品分类</title> 
</head>
<body style="background:#eef3f7;">
<#include "/views/ftl/base/head.ftl"> 
<div class="Main">
  <div class="dw">
<#include "/views/ftl/base/menu.ftl">
<#function a><#return "产品分类_List"></#function> 
<!--右边内容-->
<div class="Rightbox fl">
    <!--导航-->
    <div class="Bread_crbs clear">
      <div class="Bread_crbs_img fl"></div>
      <div class="Bread_crbs_text fl">
      	<a href="javascript:void(0);"><span>商品管理</span></a>
      	<span class="fnt_famy">></span>
      	<a href="javascript:void(0);"><span>产品分类</span></a>
      </div>
    </div>
      <div class="Table">
        </div>
  <!--表格列表-->
        <div class="Table"> 
        
          <div id="first_goods_category_div" class="input_name" style="height:32px;    margin-bottom: 20px;display:none;">
             <span class="left_title" style="line-height: 32px;">上级分类：</span>
             <select id="first_goods_category_list_select"  class="sp">
           			<option value="0">----</option>
			 </select>
          </div>


            <div class="input_name" style="height:32px;    margin-bottom: 20px;">
                <span class="left_title" style="line-height: 32px;">能否打折：</span>
                <select id="isCanDiscount"  class="sp">
                    <option value="1" <#if goodsCategory.isCanDiscount==1>selected="selected"</#if> >能</option>
                    <option value="0" <#if goodsCategory.isCanDiscount==0>selected="selected"</#if> >不能</option>
                </select>
            </div>
          
          <div class="input_name">
             <span class="left_title">产品分类名称：</span>
             <input type="text" name="categoryName" class="search_text tdd50" style="width:210px" value="${(goodsCategory.categoryName)!''}"> 
          </div>
          
          
          
          
         
          
          <span class="tbl_btn" style="margin-left: 300px;"> 
             <a href="javascript:void(0);"><span id="modify" style="background: #0075c5;">修改</span></a>
          </span>
			</div>

          
        </div>
</div>  
<script> 
$(function(){

	loadfirstGoodsCategoryList();
	function loadfirstGoodsCategoryList(){
		var parentId = "${((goodsCategory.parentId)?c)!''}";
		
		/*if(''==parentId){
			return ;
		}*/
		
		
		$.ajax({ 
			url : "${basePath}manager/GoodsCategory_goodsCategoryList",
			data : {
				pageNumber:1,
				pageSize:100
			}, 
			dataType :"JSON",
			cache : false, 
			type : "POST",
			success : function(dat){
				if(dat.code==1){
					 var html ='';
					 html+='<option value="">----</option> '; 
					 $(dat.data).each(function(index,bean){
					 	html+='<option value="'+bean.id+'">'+bean.categoryName+'</option> '; 
					 });
					 $('#first_goods_category_list_select').html(html);
					 
					 $('#first_goods_category_div').show();
					 $("#first_goods_category_list_select").find("option[value='"+parentId+"']").attr("selected",true);
					 $("#first_goods_category_list_select").attr("disabled","disabled");
					 
					 
				} 
			}
		});
	
	}

	
	$("#modify").click(function(){
		
		var categoryName = $("input[name=categoryName]").val();
        var isCanDiscount = $("#isCanDiscount").val();

        if(categoryName==''){
			alert("产品分类名称不能为空");
			return;
		} 
		
		$.ajax({ 
			url : "${basePath}manager/GoodsCategory_modifyGoodsCategory",
			data : { 
				goodsCategoryId:'${(goodsCategory.id)?c}',
				categoryName:categoryName,
                isCanDiscount:isCanDiscount
			},
			dataType :"JSON",
			cache : false, 
			type : "POST",
			success : function(dat){
				if(dat.code==1){
					alert(dat.msg);
					window.location.reload();
				}else{
					alert(dat.msg);	
				} 
			}
		});
	});

});

</script>
</body>
</html>

